<?php


class EmailSenderComponent extends Object{

	var $components = array('Email');
	
	function smtpMessage(){
		// Constantes do SMTP
		require_once ROOT.DS.APP_DIR.DS.'config'.DS.'mail.php';
		
		$this->Email->smtpOptions = array(
			'port'=>SMTP_PORT, 
			'timeout'=>SMTP_TIMEOUT,
			'host' => SMTP_HOST,
			'username'=> SMTP_USERNAME,
			'password'=> SMTP_PASSWORD
		);
		$this->Email->delivery = 'smtp';
	}
	
	function setLayout(){
		
	}
	
	function from($nome = null, $email = null){
		if($email == null) $email = SMTP_USERNAME;
		if($nome == null) $nome = SMTP_USERNAME;
		$this->Email->from = $nome.' <'.$email.'>';
	}
	
	function sendTo(){
		$this->Email->to = 'Somebody Else <willen.goulart@gmail.com>';
	//	$this->Email->cc = 'Somebody Else <somebody.else@example.com>';
	//	$this->Email->bcc = 'Somebody Else <willen.goulart@gmail.com>';
	}
	
	function assunto($assunto){
		$this->Email->subject = $assunto;
	}	

	function enviar(){
    	$this->Email->send();
	}
    
	function debug(){
    	echo $this->Email->smtpError;
	}
	
	
}